<template>
    <div class="myagreement-main">
        <img src="../../static/imgs/myagreenment_bg.png">
        <div class="myagreement-parent">
            <div class="myagreement-content" > 
                <div class="myagreement-title">
                    <h2>电子合同，保护您的合法权益</h2>
                    <p>电子合同等同于纸质合同，为您的合法权益保驾护航</p>
                </div>
                <ul class="myagreement-list" v-if="agreement.length > 0">
                    <li v-for="item in agreement" :key="item.appId"  @click="godetails(item.jump_data)">
                        <h3>{{item.project_name}}</h3>
                        <p>签订时间<i></i>{{item.create_time}}</p>
                    </li>
                </ul>
            </div>
        </div>
    </div>
        
</template>

<script>
    /**
     *  引入工具类库 或 Native API
     *  example : import widget from 'gapi/widget'
     */
    import * as util from 'js/util.js'
    import commonPage from 'clientApi/commonPage.js'
    import widget from 'gapi/widget.js'
    import clientInfo from 'gapi/clientInfo.js'
    import socialApi from 'clientApi/socialApi.js'
    import clientUtil from 'clientApi/util'
    /**
     *  引入组件 以及 组件接口(Action)
     *  example : import Somecomponents from 'components/Somecomponents/Somecomponents'
     */
    import Empty from 'components/Empty/Empty'
    /**
     *  组件实例对象
     */
    export default {
        components: {
            Empty
        },
        data: function(){
            return{
                agreement:[],
            }
        },
        vuex: {
            getters: {

            },
            actions: {

            }
        },
        methods: {
            /**
             * 初始化
             * @method init
             * @public
             * @return {Null} void
             */
            init (){
                commonPage.loadPageStatus('loading')

                let headers = {}
                clientInfo.getCommonHeaders(data => {
                  headers = data;
                  util.ajax({
                      url:'/protocol/list/get',
                      type:'GET',
                      data:{
                      },
                      timeout:10000,
                      headers: headers,
                      success:(obj) => {
                          commonPage.loadPageStatus('loadSuccess')
                          if(obj&&obj.errno == 0){
                              this.agreement = obj.data;
                          }else{
                              widget.toast(obj.errmsg)
                          }
                      },
                      error: (xhr, status) => {
                          commonPage.loadPageStatus('loadSuccess')
                          widget.toast('服务器异常')
                      },
                      noNetwork: () => {
                          commonPage.loadPageStatus('loadSuccess')
                          widget.toast('网络连接失败，请检查网络')
                      }
                  })
                 
                })


               
                
            },
            godetails(jump_data){

                clientInfo.getHost((host) => {
                    if(clientUtil.OS() == 'android'){
                        let android_url = '/sea/api/1.0/client/v1/protocol/download?dmclient=pcweb&X-Doumi-Agent=weixinqy&protocol_order_id=' + jump_data.protocol_order_id + '&protocol_user_id='+ jump_data.protocol_user_id + '&protocol_sign='+ jump_data.protocol_sign;
                        let download_url = host.info + android_url
                        let data = {
                            file_name: jump_data.protocol_name,
                            download_url: download_url
                        }
                        socialApi.protocolShare(data)
                    }else{
                        let ios_url = '/sea/api/1.0/client/v1/protocol/download?dmclient=pcweb&X-Doumi-Agent=weixinqy&protocol_order_id=' + jump_data.protocol_order_id + '&protocol_user_id='+ jump_data.protocol_user_id + '&protocol_sign='+ jump_data.protocol_sign;
                        // location.href =  `dmsaas://dmbrowser/${encodeURIComponent(host.info + ios_url)}&file_name=` + jump_data.protocol_name+'&.pdf ';

                        let download_url = encodeURIComponent(host.info + ios_url) 
                        let url = `download_url=${download_url}&file_name=${jump_data.protocol_name}`
                        location.href = "dmsaas://ContractDetail?urdData="+encodeURIComponent(url)


                    }   

                });                    
            }
        },
        created(){

            this.init();
            
        }
        
    }

    
</script>

<!-- CSS 样式 -->

<style src="../../node_modules/weui/dist/style/weui.css"></style>
<style src="../../static/css/common.css"></style>
<style src="../../static/css/myagreement.css"></style>


